import request from '@/utils/request'

export function listUser(data) {
  return request({
    url: '/api/uc/user/page',
    method: 'post',
    data
  })
}

export function addUser(data) {
  return request({
    url: '/api/uc/user/save',
    method: 'post',
    data
  })
}

export function updateUser(data) {
  return request({
    url: '/api/uc/user/update',
    method: 'post',
    data
  })
}

export function updateUserBaseInfo(data) {
  return request({
    url: '/api/uc/user/update_user_base_info',
    method: 'post',
    data
  })
}

export function updateUserRole(data) {
  return request({
    url: '/api/uc/user/update_role',
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: '/api/uc/user/get_current',
    method: 'post'
  })
}

export function getUserUpdate() {
  return request({
    url: '/api/uc/user/get_user_update',
    method: 'post'
  })
}

export function listUserItemByRoleId(data) {
  return request({
    url: '/api/uc/user/list_item_by_role_id',
    method: 'post',
    data
  })
}

export function listRoleId(data) {
  return request({
    url: '/api/uc/user/list_role_id',
    method: 'post',
    data
  })
}

export function saveUserGroupUser(data) {
  return request({
    url: '/api/uc/user/save_user_group_user',
    method: 'post',
    data
  })
}

export function deleteUserGroupUser(data) {
  return request({
    url: '/api/uc/user/delete_user_group_user',
    method: 'post',
    data
  })
}

export function getUserGroupId(data) {
  return request({
    url: '/api/uc/user/get_user_group_id',
    method: 'post',
    data
  })
}

export function getUserAvatar(data) {
  return request({
    url: '/api/uc/user/get_user_avatar',
    method: 'post',
    data
  })
}

export function setUserAvatar(data) {
  return request({
    url: '/api/uc/user/set_user_avatar',
    method: 'post',
    data
  })
}

export function personalModifyPassword(data) {
  return request({
    url: '/api/auth/pwd/personal_modify_password',
    method: 'post',
    data
  })
}

/**
 * 获取用户名称
 * @param data
 * @returns {AxiosPromise}
 */
export function getUserName(data) {
  return request({
    url: '/api/uc/user/getUserName',
    method: 'post',
    data
  })
}


/**
 * 获取部门下所有人员
 * @param data
 * @returns {AxiosPromise}
 */
export function getUsersByGroupId(data) {
  return request({
    url: '/api/uc/user/get_users_by_group_id',
    method: 'post',
    data
  })
}

/**
 * 获取部门下所有人员
 * @param data
 * @returns {AxiosPromise}
 */
export function saveUser(data) {
  return request({
    url: '/api/auth/logon/save_user',
    method: 'post',
    data
  })
}

/**
 * 删除部门下用户
 * @param data
 * @returns {AxiosPromise}
 */
export function removeUser(data) {
  return request({
    url: '/api/uc/user/remove_user_group_user_rel',
    method: 'post',
    data
  })
}

// /api/uc/user/search_user_by_keyword 根据用户名/部门/角色/模糊搜索用户
export function searchUserByKeyword(data) {
  return request({
    url: '/api/uc/user/search_user_by_keyword',
    method: 'post',
    data
  })
}


// /api/uc/user/search_user_by_code
// 根据角色Code查询此角色下的所有用户
export function searchUserByCode(data) {
  return request({
    url: '/api/uc/user/search_user_by_code',
    method: 'post',
    data
  })
}


// 搜索部门/api/uc/user_group/list_by_name
export function listByName(data) {
  return request({
    url: '/api/uc/user_group/list_by_name',
    method: 'post',
    data
  })
}



/**
 * 判断权限
 * @param data
 *@requires {AxiosPromise}
 */
export function hasPermission(data) {
  return request({
    url: '/api/uc/user/has_permission',
    method: 'post',
    data
  })
}


/**
 * 禁闭/解禁用户
 * @param data
 *@requires {AxiosPromise}
 */
export function lock(data) {
  return request({
    url: '/api/uc/user/lock',
    method: 'post',
    data
  })
}